/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Registro.java
 *
 * Created on 6/05/2009, 11:04:41 PM
 */
package gui;

import conexion.RmiCliente;
import javax.swing.JFrame;
import org.jvnet.substance.SubstanceLookAndFeel;
import org.jvnet.substance.watermark.SubstanceImageWatermark;

/**
 *
 * @author arquitectura
 */
public class Home extends javax.swing.JFrame {
    private RmiCliente rc;
    private VerPerfilJugador pj;
    private String Usuario;
    private Estadisticas Est;
    /** Creates new form Registro */
    public Home(String usuario,Login in) {
        initComponents();

        this.setSize(800, 625);
        this.setLocationRelativeTo(null);
        this.Usuario = usuario;
        this.rc=new RmiCliente();
        this.rc.conectarseAlServidor(this,in);
        this.enviar();

    }

    public RmiCliente getRc() {
        return rc;
    }

    public void setRc(RmiCliente rc) {
        this.rc = rc;
    }

public void enviar()
{

        this.rc.enviarMensaje(this.Usuario); 
}
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        BTN_partida = new javax.swing.JButton();
        BTN_perfil = new javax.swing.JButton();
        BTN_estadisticas = new javax.swing.JButton();
        BTN_salir = new javax.swing.JButton();
        jtMensaje = new javax.swing.JTextField();
        jbEnviar = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtChat = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setBounds(new java.awt.Rectangle(0, 0, 0, 0));
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setForeground(java.awt.Color.white);
        setMinimumSize(new java.awt.Dimension(800, 625));
        setResizable(false);
        setUndecorated(true);

        BTN_partida.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/BTN_mpartida.png"))); // NOI18N
        BTN_partida.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        BTN_partida.setBorderPainted(false);
        BTN_partida.setContentAreaFilled(false);
        BTN_partida.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/BTN_mpartida_roll.png"))); // NOI18N
        BTN_partida.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BTN_partidaActionPerformed(evt);
            }
        });

        BTN_perfil.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/BTN_mperfil.png"))); // NOI18N
        BTN_perfil.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        BTN_perfil.setBorderPainted(false);
        BTN_perfil.setContentAreaFilled(false);
        BTN_perfil.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/BTN_mperfil_roll.png"))); // NOI18N
        BTN_perfil.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BTN_perfilActionPerformed(evt);
            }
        });

        BTN_estadisticas.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/BTN_mestadisticas .png"))); // NOI18N
        BTN_estadisticas.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        BTN_estadisticas.setBorderPainted(false);
        BTN_estadisticas.setContentAreaFilled(false);
        BTN_estadisticas.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/BTN_mestadisticas_roll.png"))); // NOI18N
        BTN_estadisticas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BTN_estadisticasActionPerformed(evt);
            }
        });

        BTN_salir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/BTN_cancelar.png"))); // NOI18N
        BTN_salir.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        BTN_salir.setBorderPainted(false);
        BTN_salir.setContentAreaFilled(false);
        BTN_salir.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/gui/BTN_cancelar_roll.png"))); // NOI18N
        BTN_salir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BTN_salirActionPerformed(evt);
            }
        });

        jtMensaje.setForeground(new java.awt.Color(255, 255, 255));
        jtMensaje.setBorder(null);
        jtMensaje.setOpaque(false);

        jbEnviar.setText("Enviar");
        jbEnviar.setOpaque(false);
        jbEnviar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbEnviarActionPerformed(evt);
            }
        });

        jtChat.setColumns(20);
        jtChat.setRows(5);
        jScrollPane1.setViewportView(jtChat);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(167, 167, 167)
                .addComponent(BTN_partida)
                .addGap(38, 38, 38)
                .addComponent(BTN_perfil)
                .addGap(32, 32, 32)
                .addComponent(BTN_estadisticas)
                .addContainerGap(147, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(185, 185, 185)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 306, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jtMensaje, javax.swing.GroupLayout.PREFERRED_SIZE, 291, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbEnviar, javax.swing.GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE)
                        .addContainerGap(286, Short.MAX_VALUE))))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(777, Short.MAX_VALUE)
                .addComponent(BTN_salir, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(51, 51, 51))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(58, 58, 58)
                .addComponent(BTN_salir, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(119, 119, 119)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(26, 26, 26)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtMensaje, javax.swing.GroupLayout.DEFAULT_SIZE, 41, Short.MAX_VALUE)
                    .addComponent(jbEnviar))
                .addGap(100, 100, 100)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(BTN_partida)
                    .addComponent(BTN_perfil)
                    .addComponent(BTN_estadisticas))
                .addGap(43, 43, 43))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void BTN_partidaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BTN_partidaActionPerformed
        // TODO add your handling code here:
        this.setVisible(false);
        CrearPartida cp=new CrearPartida(this,this.Usuario);
        JFrame.setDefaultLookAndFeelDecorated(true);

        SubstanceLookAndFeel.setSkin("org.jvnet.substance.skin.CremeSkin");
        //SubstanceLookAndFeel.setCurrentWatermark("org.jvnet.substance.watermark.SubstanceBinaryWatermark");//Ejemplo de aplicacion de un watermark de Substance
        SubstanceLookAndFeel.setCurrentWatermark(new SubstanceImageWatermark("http://72.29.81.246/~imindjav/images/CrearPartida.jpg"));
        SubstanceLookAndFeel.setImageWatermarkOpacity(new Float(1));
        cp.setVisible(true);
    }//GEN-LAST:event_BTN_partidaActionPerformed

    private void BTN_perfilActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BTN_perfilActionPerformed
        // TODO add your handling code here:
         this.setVisible(false);
        pj = new VerPerfilJugador(Usuario, this);
        JFrame.setDefaultLookAndFeelDecorated(true);

    SubstanceLookAndFeel.setSkin("org.jvnet.substance.skin.CremeSkin");
    //SubstanceLookAndFeel.setCurrentWatermark("org.jvnet.substance.watermark.SubstanceBinaryWatermark");//Ejemplo de aplicacion de un watermark de Substance
    SubstanceLookAndFeel.setCurrentWatermark(new SubstanceImageWatermark("http://72.29.81.246/~imindjav/images/VerPerfilAdmin.jpg"));
    SubstanceLookAndFeel.setImageWatermarkOpacity(new Float(1));
        pj.setVisible(true);
    }//GEN-LAST:event_BTN_perfilActionPerformed

    private void BTN_estadisticasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BTN_estadisticasActionPerformed
        // TODO add your handling code here:
        this.setVisible(false);
        
          JFrame.setDefaultLookAndFeelDecorated(true);

        SubstanceLookAndFeel.setSkin("org.jvnet.substance.skin.CremeSkin");
        //SubstanceLookAndFeel.setCurrentWatermark("org.jvnet.substance.watermark.SubstanceBinaryWatermark");//Ejemplo de aplicacion de un watermark de Substance
        SubstanceLookAndFeel.setCurrentWatermark(new SubstanceImageWatermark("http://72.29.81.246/~imindjav/images/Estadisticas.jpg"));
        SubstanceLookAndFeel.setImageWatermarkOpacity(new Float(1));
        
        Est = new Estadisticas(Usuario,rc, this );
        Est.setVisible(true);
        //public Estadisticas(String usuario, RmiCliente rc, guiCliente gc)
        
    }//GEN-LAST:event_BTN_estadisticasActionPerformed

    private void BTN_salirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BTN_salirActionPerformed
        // TODO add your handling code here:
        this.setVisible(false);
        this.rc.salirSistema(this.Usuario);
        this.rc.salir(this);
    }//GEN-LAST:event_BTN_salirActionPerformed

    private void jbEnviarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbEnviarActionPerformed
        // TODO add your handling code here:
        
        String men = this.rc.nuevomsg(this.Usuario, this.jtMensaje.getText());
        
        
        if(men.equals("nada")) {
        } else {
            this.jtChat.setText(men);
            
        }
        
        this.jtMensaje.setText("");
    }//GEN-LAST:event_jbEnviarActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {

        JFrame.setDefaultLookAndFeelDecorated(true);

        SubstanceLookAndFeel.setSkin("org.jvnet.substance.skin.CremeSkin");
        //SubstanceLookAndFeel.setCurrentWatermark("org.jvnet.substance.watermark.SubstanceBinaryWatermark");//Ejemplo de aplicacion de un watermark de Substance
        SubstanceLookAndFeel.setCurrentWatermark(new SubstanceImageWatermark("http://72.29.81.246/~imindjav/images/Home.jpg"));
        SubstanceLookAndFeel.setImageWatermarkOpacity(new Float(1));
/*
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Home().setVisible(true);
            }
        });*/
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BTN_estadisticas;
    private javax.swing.JButton BTN_partida;
    private javax.swing.JButton BTN_perfil;
    private javax.swing.JButton BTN_salir;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton jbEnviar;
    private javax.swing.JTextArea jtChat;
    private javax.swing.JTextField jtMensaje;
    // End of variables declaration//GEN-END:variables
}
